<?php

/**
 * This is the model class for table "ssh_setup".
 *
 * The followings are the available columns in table 'ssh_setup':
 * @property string $id_ssh_setup
 * @property integer $id_account
 * @property string $ssh_port
 * @property integer $pass_or_key
 * @property string $user
 * @property string $pass
 * @property integer $switch_user_required
 * @property string $su_user
 * @property string $su_pass
 * @property string $initial_prompty
 * @property string $pass_prompty
 * @property string $privaty_key
 */
class SshSetup extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return SshSetup the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'ssh_setup';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('id_account, ssh_port, user, pass', 'required'),
			array('ssh_port', 'numerical', 'integerOnly'=>true),
			array('id_account, ssh_port, pass_or_key, user, pass, switch_user_required, su_user, su_pass, initial_prompty, pass_promptyy, privaty_key', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('su_user, su_pass, initial_prompty, pass_promptyy', 'required', 'on'=>'switch_user_required'),
//			array('public_key', 'required', 'on'=>'use_key'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'Whmaccount' => array(self::BELONGS_TO, 'WhmAccount', 'id_account'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ssh_port' => 'SSH Port: ',
			'private key' => 'RSA Private Key ',
			'is_public_key_active_on_server' => 'SSH Public-Key active on server. ',
			'user' => 'Username: ',
			'pass' => 'Password:',
			'switch_user_required' => 'Switch User Required ',
			'su_user' => 'su Username: ',
			'su_pass' => 'su Password: ',
			'initial_prompty' => 'Initial Prompt: ',
			'pass_promptyy' => 'Password Prompt: ',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id_ssh_setup',$this->id_ssh_setup,true);
		$criteria->compare('id_account',$this->id_account);
		$criteria->compare('ssh_port',$this->ssh_port,true);
		$criteria->compare('pass_or_key',$this->pass_or_key);
		$criteria->compare('user',$this->user,true);
		$criteria->compare('pass',$this->pass,true);
		$criteria->compare('switch_user_required',$this->switch_user_required);
		$criteria->compare('su_user',$this->su_user,true);
		$criteria->compare('su_pass',$this->su_pass,true);
		$criteria->compare('initial_prompty',$this->initial_prompty,true);
		$criteria->compare('pass_prompty',$this->pass_prompty,true);
		$criteria->compare('privaty_key',$this->privaty_key,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}